<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">

		<ui:define name="content">


			<h:panelGrid>
				
				<p:treeTable id="paths" value="#{buyTicketBean.root}" var="path"
					selection="#{buyTicketBean.selectedNode}" selectionMode="single"
					scrollable="true" scrollHeight="300" dynamic="true">

					<f:facet name="header">
                       Trains and traces.
                    </f:facet>

					<p:column style="width:20%">
						<f:facet name="header">
                         Name
                         </f:facet>
						<h:outputText value="#{path.number}" />
					</p:column>

					<p:column style="width:15%">
						<f:facet name="header">
                           Departure station
                        </f:facet>
						<h:outputText value="#{path.departureStation}" />
					</p:column>

					<p:column style="width:25%">
						<f:facet name="header">
                           Departure time
                        </f:facet>
						<h:outputText value="#{path.departureTime}" />

					</p:column>


					<p:column style="width:15%">
						<f:facet name="header">
                           Arrival station
                         </f:facet>
						<h:outputText value="#{path.arrivalStation}" />
					</p:column>


					<p:column style="width:25%">
						<f:facet name="header">
                           Arrival time
                        </f:facet>
						<h:outputText value="#{path.arrivalTime}" />

					</p:column>
				</p:treeTable>




				<h:panelGroup>
					<h:panelGrid columns="5">

						<h:outputText value="Select departure station:" />
						<h:outputText value="Select arrival station:" />
						<h:outputText value="Select departure time:" />
						<h:outputText value="Select arrival time:" />

						<p:commandButton value="Find"
							action="#{buyTicketBean.findTrain()}" update="paths" />




						<p:selectOneMenu value="#{buyTicketBean.departureStation}"
							converter="stationConverter" effect="fade" var="s" filter="true"
							filterMatchMode="startsWith">
							<f:selectItem itemLabel="Select One" itemValue="" />
							<f:selectItems value="#{buyTicketBean.stations}" var="station"
								itemValue="#{station}" itemLabel="#{station.name}" />


							<p:column>
                          #{s.name}
                         
						</p:column>
						</p:selectOneMenu>

						<p:selectOneMenu value="#{buyTicketBean.arrivalStation}"
							converter="stationConverter" effect="fade" var="s" filter="true"
							filterMatchMode="startsWith">
							<f:selectItem itemLabel="Select One" itemValue="" />
							<f:selectItems value="#{buyTicketBean.stations}" var="station"
								itemValue="#{station}" itemLabel="#{station.name}" />
							<p:column>
                            #{s.name}
                       	    </p:column>
						</p:selectOneMenu>

						<p:calendar value="#{buyTicketBean.departureTime}"
							pattern="MM/dd/yyyy HH:mm" />


						<p:calendar value="#{buyTicketBean.arrivalTime}"
							pattern="MM/dd/yyyy HH:mm" />

						<p:commandButton value="Buy ticket"
							action="#{buyTicketBean.buyTicket()}" />





					</h:panelGrid>
				</h:panelGroup>

			</h:panelGrid>





		</ui:define>


	</ui:composition>

</h:body>
</html>